'''------------------------------------------------------------------------------
# Project:     World Exposition game
# Name:        fence
# Purpose:     Object the player cannot pass
# 
# Authors:     Sam Milender, Calvin Berger
# Main Author: Sam Milender
#
# Created:     May 13, 2013
# Copyright:   (c) Sam Milender 2013
# Licence:     New BSD
#------------------------------------------------------------------------------
'''
import pygame, math, sys, random

class Fence(pygame.sprite.Sprite):
    def __init__(self, position, screenSize, image):
        pygame.sprite.Sprite.__init__(self, self.containers)
        self.images = []
        self.images = [pygame.image.load(image)]
        self.frame = 0
        self.maxFrame = len(self.images)-1
        self.image = self.images[self.frame]
        self.rect = self.image.get_rect()
        self.realx = position[0]
        self.realy = position[1]
        self.xOffset = 0
        self.yOffset = 0
        self.place(position)
        self.scrolling = False
        
        
    def  __str__(self):
        return "I'm a ball :3" + str(self.rect.center) + str(self.speed) + str(self.living)
        pass
        
    def move(self):
        self.place([self.realx-self.xOffset, self.realy-self.yOffset])
     
    def place(self, position):
        self.rect.center = position
        #print "I've moved to", position
        
    def distToPoint(self, pt):
        x1 = self.rect.center[0]
        x2 = pt[0]
        y1 = self.rect.center[1]
        y2 = pt[1]
        return math.sqrt(((x2-x1)**2)+((y2-y1)**2))
   
    def update(*args):
        self = args[0]
        self.xOffset = args[1]
        self.yOffset = args[2]
        self.scrollingX = args[3]
        self.scrollingY = args[4]
        self.move()